<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class uindex extends CI_Controller {

    var $theme_data = array(
        'layout_main' => 'layout',
        'left' => 'include/leftcp',
    );
var $resource = "";
    function __construct() {
        parent::__construct();
        $this->load->model("madmin");
		$this->resource = new stdClass;
		$this->load->model("mresourcegroups");
    }

    public function index() {
        $data = array();
        if ($this->madmin->checkLogin()) {
			$this->resource->RES_NAME = "Bảng điều khiển";
            $this->theme_data["main"] = "admin/dashboard";
			$this->load->model("mgame");
			$data['game']['total'] = $this->mgame->num();
			$data['game']['status_h3'] = $this->mgame->num(-3,'game_status');
			$data['game']['status_h2'] = $this->mgame->num(-2,'game_status');
			$data['game']['status_h1'] = $this->mgame->num(-1,'game_status');
			$data['game']['status_0'] = $this->mgame->num('0','game_status');
			
			$data['game']['status_1'] = $this->mgame->num('0','game_status >');
            $this->template->viewAdmin($this->theme_data, $data);
        } else {
			$this->theme_data["left"] = null;
            $this->theme_data["main"] = "admin/login";
            $this->template->viewAdmin($this->theme_data, $data);
        }
    }
	
	public function nopermission() {
		if (!$this->madmin->checkLogin()) {
			redirect(admin_url());
		}
		$this->resource = new stdClass;
		$this->resource->RES_NAME = "No Permission";
		$this->theme_data["main"] = "include/no-permission";
		 $this->template->viewAdmin($this->theme_data);
	}
	function logout(){
		$this->madmin->logout();
		redirect(admin_url());
	}
}
